import { Component } from "react";

// 引入 store
import store from "../store";

import {
  increment,
  changeMsg,
  incrementTwo,
  changeMsgTwo,
} from "../store/actionCreators";

export default class World extends Component {
  render() {
    // 获取 state
    const state = store.getState();

    return (
      <div>
        <h2>World</h2>
        <p>msg: {state.msg}</p>
        <p>count: {state.count}</p>
        {/* <button onClick={() => store.dispatch(increment())}>INCREMENT</button> */}
        <button onClick={() => incrementTwo(store.dispatch)}>INCREMENT</button>
        {/* <button onClick={() => store.dispatch(changeMsg())}>CHANGEMSG</button> */}
        <button onClick={() => changeMsgTwo(store.dispatch)}>CHANGEMSG</button>
        <button onClick={() => changeMsgTwo(store.dispatch, "张三")}>
          CHANGEMSG-张三
        </button>
        <button onClick={() => changeMsgTwo(store.dispatch, "里斯")}>
          CHANGEMSG-里斯
        </button>
      </div>
    );
  }
}
